package ChessBoard;

import java.util.ArrayList;


public abstract class Figure {
	public boolean isWhite;
	public int value;
	boolean checks = false;
	ChessBoard correspondingBoard;
	public int coveredBy;
	public int[] position;// x,y
	public ArrayList<int[]> moves;
	public ArrayList<Figure> kills;
	public ArrayList<Figure> covers;

	public Figure(boolean isWhite, int[] position,ChessBoard correspondingBoard) {
		this.isWhite = isWhite;
		this.position = position;
		this.coveredBy = 0;
		this.moves = new ArrayList<int[]>();
		this.covers = new ArrayList<Figure>();
		this.kills = new ArrayList<Figure>();
		this.correspondingBoard = correspondingBoard;
	}

	public abstract void checkCheck();

	/**
	 * @return the coveredBy
	 */
	public int getCoveredBy() {
		return coveredBy;
	}

	/**
	 * @param coveredBy
	 *            the coveredBy to set
	 */
	public void setCoveredBy(int coveredBy) {
		this.coveredBy = coveredBy;
	}

	/**
	 * @return the position
	 */
	public int[] getPosition() {
		return position;
	}

	/**
	 * @param position
	 *            the position to set
	 */
	public void setPosition(int[] position) {
		this.position = position;
	}

	/**
	 * @return the moves
	 */
	public ArrayList<int[]> getMoves() {
		return moves;
	}

	/**
	 * @param moves
	 *            the moves to set
	 */
	public void setMoves(ArrayList<int[]> moves) {
		this.moves = moves;
	}

	/**
	 * @return the kills
	 */
	public ArrayList<Figure> getKills() {
		return kills;
	}

	/**
	 * @param kills
	 *            the kills to set
	 */
	public void setKills(ArrayList<Figure> kills) {
		this.kills = kills;
	}

	/**
	 * @return the covers
	 */
	public ArrayList<Figure> getCovers() {
		return covers;
	}

	/**
	 * @param covers
	 *            the covers to set
	 */
	public void setCovers(ArrayList<Figure> covers) {
		this.covers = covers;
	}

	public void calculatePossibleMove() {
		ArrayList<int[]> newMoves = new ArrayList<int[]>();
		newMoves = calculatePos();
		this.setMoves(newMoves);
	}

	protected abstract ArrayList<int[]> calculatePos();



	protected void resetAll() {
		this.moves = new ArrayList<int[]>();
		this.covers = new ArrayList<Figure>();
		this.kills = new ArrayList<Figure>();
	}

}
